package it.scambiocorse.dao;

import it.scambiocorse.model.AutistaType;
import it.scambiocorse.model.ServizioType;
import it.scambiocorse.model.SorgenteType;
import it.scambiocorse.utils.Utils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;

import org.springframework.jdbc.core.PreparedStatementCreator;

import com.mysql.jdbc.Statement;

public class PSCAutista implements PreparedStatementCreator {
	
private AutistaType a;
private String sql;

PSCAutista () {}
PSCAutista (AutistaType a, String sql) {
	this.a = a;
	this.sql = sql;
}
PSCAutista (AutistaType a) {
	this.a = a;
}

	public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
		String sql = "insert into autista_tab (" +
				  "id_autista_user," +
				  "id_user_inse," +
				  "nome," +
				  "email," +
				  "tel," +
				  "note," +
				  "data_inse" +
				  ") " +

				  	" values (?,?,?,?,?,?,?)";
		
		
		PreparedStatement ps = connection.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
		ps.setInt(1, a.getIdAutistaUser());
		ps.setInt(2, a.getIdUserInse());
		ps.setString(3, a.getNome());
		ps.setString(4, a.getEmail());
		ps.setString(5, a.getTel());
		ps.setString(6, a.getNote());
		ps.setTimestamp(7, Utils.getSysDate());

		
		
	return ps;
	}
}
